import { Api, Field, Get, Model } from 'easy-descriptor'
import { BaseModel } from '@/hooks/useModel'
import { BaseApi } from '@/hooks/useApi'

@Model('GenModule')
export default class GenModule extends BaseModel {
  @Field()
  $selection?: boolean

  @Field()
  $index?: number

  @Field('模块名称')
  name?: string

  @Field('模块编码')
  moduleCode?: string

  @Field('包名', {
    formSpan: 2
  })
  pkg?: string

  @Field('Entity')
  entity?: string

  @Field('Mapper')
  mapper?: string

  @Field('Xml')
  mapperXml?: string

  @Field('Service')
  service?: string

  @Field('ServiceImpl')
  serviceImpl?: string

  @Field('Controller')
  controller?: string

  @Field('webList')
  webList?: string

  @Field('webModel')
  webModel?: string

  files?: string[]
}

@Api('/gen/module/')
export class GenModuleApi extends BaseApi {
  @Get('findByCode/{code}')
  static getModule: HttpReq<GenModule, { code: string }>
}

export type GeneratorFile = {
  type?: string
  pkg?: string
  path?: string
  template?: string
  templateContent?: string
  className?: string
  outputName?: string
}

// @Model()
export type GeneratorData = {
  tableId: string
  author?: string
  files: string[]
  moduleCode: string
  templateType: string
  templateContents: string[]
}
